package cn.stylefeng.guns.modular.business.controller;

import cn.stylefeng.guns.modular.business.pojo.CyclopediaInfoRequest;
import cn.stylefeng.guns.modular.business.service.CyclopediaInfoService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 百科信息表控制器
 *
 * @author zhangyaowen
 * @date 2021/11/05 15:32
 */
@RestController
@ApiResource(name = "百科信息表")
public class CyclopediaInfoController {

    @Resource
    private CyclopediaInfoService cyclopediaInfoService;

    /**
     * 添加
     *
     * @author zhangyaowen
     * @date 2021/11/05 15:32
     */
    @PostResource(name = "添加", path = "/cyclopediaInfo/add")
    public ResponseData add(@RequestBody @Validated(CyclopediaInfoRequest.add.class) CyclopediaInfoRequest cyclopediaInfoRequest) {
        cyclopediaInfoService.add(cyclopediaInfoRequest);
        return new SuccessResponseData();
    }

    /**
     * 删除
     *
     * @author zhangyaowen
     * @date 2021/11/05 15:32
     */
    @PostResource(name = "删除", path = "/cyclopediaInfo/delete")
    public ResponseData delete(@RequestBody @Validated(CyclopediaInfoRequest.delete.class) CyclopediaInfoRequest cyclopediaInfoRequest) {
        cyclopediaInfoService.del(cyclopediaInfoRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑
     *
     * @author zhangyaowen
     * @date 2021/11/05 15:32
     */
    @PostResource(name = "编辑", path = "/cyclopediaInfo/edit")
    public ResponseData edit(@RequestBody @Validated(CyclopediaInfoRequest.edit.class) CyclopediaInfoRequest cyclopediaInfoRequest) {
        cyclopediaInfoService.edit(cyclopediaInfoRequest);
        return new SuccessResponseData();
    }

    /**
     * 查看详情
     *
     * @author zhangyaowen
     * @date 2021/11/05 15:32
     */
    @GetResource(name = "查看详情", path = "/cyclopediaInfo/detail")
    public ResponseData detail(@Validated(CyclopediaInfoRequest.detail.class) CyclopediaInfoRequest cyclopediaInfoRequest) {
        return new SuccessResponseData(cyclopediaInfoService.detail(cyclopediaInfoRequest));
    }

    /**
     * 获取列表
     *
     * @author zhangyaowen
     * @date 2021/11/05 15:32
     */
    @GetResource(name = "获取列表", path = "/cyclopediaInfo/list")
    public ResponseData list(CyclopediaInfoRequest cyclopediaInfoRequest) {
        return new SuccessResponseData(cyclopediaInfoService.findList(cyclopediaInfoRequest));
    }

    /**
     * 获取列表（带分页）
     *
     * @author zhangyaowen
     * @date 2021/11/05 15:32
     */
    @GetResource(name = "分页查询", path = "/cyclopediaInfo/page")
    public ResponseData page(CyclopediaInfoRequest cyclopediaInfoRequest) {
        return new SuccessResponseData(cyclopediaInfoService.findPage(cyclopediaInfoRequest));
    }

    /**
     * 获取第一级列表
     *
     * @author zhangyaowen
     * @date 2021/11/05 15:32
     */
    @GetResource(name = "获取第一级列表", path = "/cyclopediaInfo/findFirst")
    public ResponseData findFirst() {
        return new SuccessResponseData(cyclopediaInfoService.findFirst());
    }

    /**
     * 获取第二级列表
     *
     * @author zhangyaowen
     * @date 2021/11/05 15:32
     */
    @GetResource(name = "获取第二级列表", path = "/cyclopediaInfo/findSecond")
    public ResponseData findSecond(String cycFirst) {
        return new SuccessResponseData(cyclopediaInfoService.findSecond(cycFirst));
    }

    /**
     * 获取第一级列表
     *
     * @author zhangyaowen
     * @date 2021/11/05 15:32
     */
    @GetResource(name = "获取获取百科词条列表", path = "/cyclopediaInfo/findEntry")
    public ResponseData findEntry(String cycFirst, String cycSecond) {
        return new SuccessResponseData(cyclopediaInfoService.findEntry(cycFirst,cycSecond));
    }

    /**
     * 获取百科词条详细信息
     *
     * @author zhangyaowen
     * @date 2021/11/05 15:32
     */
    @GetResource(name = "获取百科词条详细信息", path = "/cyclopediaInfo/toReview")
    public ResponseData toReview(String id) {
        return new SuccessResponseData(cyclopediaInfoService.toReview(id));
    }

}